navigationGo.pngQuick Navigation
allprojects32.pngAll projects
hardware32.pngHardware
links32.pngLinks

favoriteStar32.pngTop projects
Alan numitron clock
Clapclap 2313/1386
SNES Pi Webserver
USB Volume/USB toys
Smokey amp
Laser cutter
WordClock
ardReveil v3
SNES Arcade cabinet
Game boy projects
cameleon
Home Presence Detector

github32.pngGitHub
AlanFromJapan

navigationMail.pngContact me

alanfjmail.png
3flags.pngWho's Alan?


Akizukidenshi
Elec-lab
Rand Nerd Tut
EEVblog
SpritesMods
AvrFreaks
Gameboy Dev
FLOZz' blog
Switch-science
Sparkfun
Suzusho
Datasheet Lib
Reddit Elec
Ermicro
Carnet du maker (fr)

smartphone media keyboard

Last update: Thu Jun 5 22:25:41 2025
Need to press Play/Pause quickly on your cellphone while listening to music and charging at the same time.

Presentation

Principle

A small USB Consumer device (not a keyboard!) you'd plug on your cellphone and allow to 1) charge it and 2) do basic media function such as Play/Pause, Next, Prev, and Vol+ and Vol- if I feel fancy. The reason is that while I like to work with my music, going next forces me to touch button to see the screen, then touch another tiny tiny button to press Next or Pause. I like to surf through my music to find something that match the mood or the task at hand, so I do that often and that's a (minor) pain. And an excellent pretext to tinker :)

Points of interrest

  • As simple implementation of a media keyboard, very very similar to the Usb Volume Control I made (and works just fine)
  • Implementation

    Bill of materials

    Schematics

    Source code

    
    #define VOL_UP		0xe9
    #define VOL_DOWN	0xea
    #define VOL_MUTE	0xe2
    #define PLAY_PAUSE 	0xcd
    #define NEXT            0x??
    

    Going USB-C

    Smartphones generations passed since I had this idea and left it on the shelf. Now the standard for smartphones is USB-C, and there is little resources on how to do your own USB-C OTG cable. Managed to find this one, after buying some on the Alibay space, that I couldn't make work.
    My goal is to have a board directly plugged in the phone, no cable (USB-C OTG cables are easy to find). I want a small board I can just plug in the phone and get my 2-3 buttons keyboard.
    πŸ‘‡This WORKSγ€€πŸ˜πŸ‘‡
    You want an OTG cable that sinks current (the smartphone will provide power to my mini keyboard).
    Found in this link and this one, and that one.
    To make a USB-C OTG male cable, from a male USB-C connector:
  • USB-C Male connector A1 ⇨ GND (alternate pins are B1, A12, B12)
  • USB-C Male connector A4 ⇨ VCC (alternate pins are B4, A9, B9)
  • USB-C Male connector A5 ⇨ pull-down to GND(A1) via a 5.1k ohm (+/- 20%)
  • USB-C Male connector A6 ⇨ D+
  • USB-C Male connector A7 ⇨ D-
  • πŸ‘‡This DOESN'T WORK βŒπŸ™…πŸ‘‡
    As an OTG cable to sink current this doesn't work, with a 56k ohm pull-up you end with an USB cable that will source current to your smartphone. At least that is what it means from the USB-C definition, and that is NOT what I plan to do now. It however explains why the cable I bought on Aliexpress didn't work (in my use case).
    You could change my design the receive power from an external outlet and then pass that power to the smartphone with that sourcing cable to charge it, but this is not the present design. Do the changes if you like.

    Pictures

    Links

    Helpful sources

  • Apparently one can be OTG slave AND provide power if FIRST it connects the power wires only AND THEN connects the data wires? link
  • Another gentleman with a similar (?) design said he can charge and be OTG link
  • ... and it continues and lead to here after passing through a site that makes me feel good about my website design skills. I include the image schematic here, in case.
  • Inspiration

  • Usb Volume Control is nearly identical, remove the spinning encoder for volume and add 2 buttons. Done.
  • All content on this site is shared under the MIT licence (do what u want, don't sue me, hat tip appreciated)
    electrogeek.tokyo ~ Formerly known as Kalshagar.wikispaces.com and electrogeek.cc (AlanFromJapan [2009 - 2025])